<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	String uid=request.getParameter("uid");
	String rid=request.getParameter("rid");
%>      
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<title></title>
		<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
		<link href="https://cdn.bootcss.com/jquery-mobile/1.4.5/jquery.mobile.theme.css" rel="stylesheet">

		<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
		<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
		<script type="text/javascript">
			$(function(){
				//加载课题类别 下拉框
				loadMeetingType();
				//加载所有可抢单列表
				loadGrabList("0");
			
			})
			//加载课题类别 下拉框
			function loadMeetingType(){
				$.ajax({
					type:"post",
					url:"meetingType/getAll",
					success:function(msg){
						var appendHtml="<option value='0'>全部</option>";
						for(var i=0;i<msg.length;i++){
							appendHtml+="<option value="+msg[i].title+">"+msg[i].title+"</option>";
						}
						$("#selectStatus").append(appendHtml);
					}
					
				});
			}
			
			//加载所有可抢单列表
			function loadGrabList(typeVal){
				var uid=$("#uid").val();
				var rid=$("#rid").val();
				$.ajax({
					type:"post",
					url:"meetingGrab/getGrabList",
					data:{"uid":uid,"type":typeVal},
					success:function(msg){
						$("#grabDiv").empty();
						$("#grabNum").empty();
						$("#grabNum").append(msg.length);
						var appendHtml="";
						for(var i=0;i<msg.length;i++){
							var mname=msg[i].ptitle;
							var remark=msg[i].title;
							var dateCurr=msg[i].pcode;
							
							appendHtml += "<div style='width: 100%;background-color: white;margin-top: -3px;padding:10px 10px 10px 15px;display: inline-block;'>" +
							"<div style='width: 70%;float: left;' onclick='showMeetingInfo(\"" + 1 + "\");'>" +
							"<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;font-size:18px;'>" +
							mname + "</div>" +
							"<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;color: #777777;font-size:16px;padding-top:1px'>" +
							remark + " / " + dateCurr + "</div></div>" +
							"<div style='width: 30%;float: right;'>" ;
							if(rid=="2"){
								appendHtml+="<button class='able-btn' onclick='grabAdd(\""+msg[i].pid+"\",\""+uid+"\")' >可抢单</button>";
							}
							appendHtml+="</div></div>";
							
						}
						$("#grabDiv").append(appendHtml);
					}
				
				});
				
			}
			//进行抢单
			function grabAdd(pid,uid){
				window.location.href="pages/weixin/meetingGrab/meetingGrab_add.jsp?pid="+pid+"&uid="+uid;
				
			}
			
			
		
		function showPubDiv() {
				$("#two_line").css("border-top", "5px solid #4E90C7");
				//$("#two_tab").css("color","#777777");
				$("#one_line").css("border-top", "5px solid white");
				//$("#one_tab").css("color","white");
				$("#two").css("display", "none");
				$("#one").css("display", "block");
			}

			function showMyMeetings() {

				$("#two_line").css("border-top", "5px solid white");
				$("#one_line").css("border-top", "5px solid #4E90C7");
			
					$("#one").css("display", "none");
					$("#two").css("display", "block");

					$("#two").empty();
					var uid=$("#uid").val();
					$.ajax({
						type:"post",
						url:"meetingGrab/getMyGrabList",
						data:{"uid":uid},
						success:function(msg){
							
							var appendHtml = "<font style='padding: 10px 10px 10px 15px;display: block;color: #777777;'>您共发布了"+msg.length+"场会议</font>";
					
							for(var i=0;i<msg.length;i++){
								var ptitle=msg[i].ptitle;
								var title=msg[i].title;
								var pcode=msg[i].pcode;
								var grabStatus=msg[i].meetingGrab.grabStatus;
								appendHtml += "<div style='width: 100%;background-color: white;margin-top: -3px;padding:10px 10px 10px 15px;display: inline-block;'>" +
								"<div style='width: 70%;float: left;' onclick='showMeetingInfo(\"" + 1 + "\");'>" +
								"<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;font-size:18px;'>" +
								ptitle + "</div>" +
								"<div style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis;display: block;color: #777777;font-size:16px;padding-top:1px'>" +
								title + " / " + pcode + "</div></div>" +
								"<div style='width: 30%;float: right;'>" ;
								if("0"==grabStatus){
									appendHtml+="审批中";
								}else if("1"==grabStatus){
									appendHtml+="<font color='red' >审批成功</font>";
								}else if("2"==grabStatus){
									appendHtml+="匹配失败";
								}
								appendHtml+="</div></div>";
							}
							$("#two").append(appendHtml);
						}
					});
					
			
			}
		</script>	
	</head>

	<body>
	<div data-role="page" id="pageDetail">
			<input type="hidden" id="uid" name="uid" value="<%=uid%>">
			<input type="hidden" id="rid" name="rid" value="<%=rid%>">
			<div style="padding:0px;background-color: #4E90C7;width: 100%;height:40px;line-height:40px;font-size:18px;text-align: center;cursor: pointer;" data-role="none">
				<div style="width: 50%;float: left;color: white;" onclick="showPubDiv();" id="one_tab">
					抢单
					<div style="border-right: 1px solid white;float: right;margin-top: 10px;height: 20px;"></div>
				</div>
				<div style="width: 50%;float: left;color: white;" onclick="showMyMeetings();" id="two_tab">我的抢单</div>
				<div style="border-top:5px solid white;width: 50%;float: left;" id="one_line"></div>
				<div style="border-top:5px solid #4E90C7;width: 50%;float: left;" id="two_line"></div>
			</div>
	<div id="one" class="ui-body-d ui-content" style="padding:0;display: block;width: 100%;">
		<div style="padding:0 0 0 15px;display: block;width: 55%;float: left;line-height: 60px;color: #777777;">
			可参与<font id="grabNum"></font>场会议的抢单
		</div>
		<div style="width: calc(45% - 15px);float: right;">
			<select id="selectStatus"  onchange="loadGrabList(this.value)">

			</select>
		</div>
		<div id="grabDiv" style="width: 100%;float: left;">

		</div>
	</div>
			

	
	
			
	<div id="two" class="ui-body-d ui-content" style="padding: 0;display: none;width: 100%;">
	</div>
	</body>

</html>